<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        document.onkeydown=function(ev){
            var oEvent=ev||event;
            alert(oEvent.keyCode);//keyCode帮助检测用户按的是哪一个按键
        };
    </script>
</head>
<body>

</body>
</html>
<!--onkeydown  键盘按下-->
<!--onkeyup    键盘抬起-->